<template>
	<div>
		<el-card shadow="hover">
			<div class="mb15">
				<el-input v-model="state.tableData.param.telephone" size="default" placeholder="请输入手机号" clearable style="max-width: 180px"> </el-input>
				<el-button size="default" type="primary" class="ml10" @click="getTableData">
					<el-icon>
						<ele-Search />
					</el-icon>
					查询
				</el-button>
			</div>
			<el-table
				border
        ref="tableRef"
				:data="state.tableData.data"
				style="width: 100%"
				row-key="id"
				v-loading="state.tableData.loading"
			>
				<el-table-column type="index" label="序号" align="center" width="70" />
				<el-table-column prop="ipstr" label="ipstr" align="center" show-overflow-tooltip min-width="150"> </el-table-column>
				<el-table-column prop="ipaddress" label="ip地址" align="center" show-overflow-tooltip min-width="150"></el-table-column>
				<el-table-column prop="ipport" label="ipport" align="center" show-overflow-tooltip width="150"></el-table-column>
				<el-table-column prop="ipuser" label="ipuser" align="center" show-overflow-tooltip width="150"></el-table-column>
				<el-table-column prop="ippwd" label="ippwd" align="center" show-overflow-tooltip width="120"></el-table-column>
				<el-table-column prop="userid" label="手机号码" align="center" show-overflow-tooltip width="120"></el-table-column>
				<el-table-column prop="simulatorid" label="simulatorid" align="center" show-overflow-tooltip width="120"></el-table-column>
				<el-table-column prop="mac" label="mac" align="center" show-overflow-tooltip width="120"></el-table-column>
				<el-table-column prop="createAt" label="创建时间" align="center" show-overflow-tooltip width="170">
					<template #default="scope">
						{{ scope.row.createAt && formatDate(new Date(scope.row.createAt), 'YYYY-mm-dd HH:MM:SS') }}
					</template>
				</el-table-column>
			</el-table>
			<!-- 分页组件 -->
			<Pagination 
				class="mt15"
				:total="state.tableData.total"
				:page="state.tableData.param.pageNum"
				:limit="state.tableData.param.pageSize"
				@pagination="pageChange"
			/>
		</el-card>
	</div>
</template>

<script setup lang="ts" name="systemIpProxy">
import { formatDate } from '/@/utils/formatTime';
// 后台接口
import { systemApi } from '/@/api/system/index';
const tableRef = ref()
const state = reactive<SysComputerState>({
	tableData: {
		data: [],
		total: 0,
		loading: false,
		param: {
      telephone: '',
			pageNum: 1,
			pageSize: 10,
		},
	},
});
// 初始化表格数据
const getTableData = async () => {
	state.tableData.loading = true;
	// 清除勾选
	tableRef.value.clearSelection()
	let res: any = await systemApi().getIpProxyList(state.tableData.param);
	state.tableData.data = res.datas.list;
	state.tableData.total = res.datas.count;
	state.tableData.loading = false;
};

// 分页组件改变
const pageChange = (pageObj: {pageNum:number,pageSize:number}) => {
	state.tableData.param.pageNum = pageObj.pageNum;
	state.tableData.param.pageSize = pageObj.pageSize;
	getTableData();
}
// 页面加载时
onMounted(() => {
	getTableData();
});
</script>
